﻿using System;

namespace enyo.db8
{
    [NonScript]
    public abstract class Collate
    {
        public static implicit operator Collate(string val)
        {
            return null;
        }

        /// <summary>
        /// Does binary comparison.
        /// </summary>
        [EvalAtCompile]
        public const string Default = "default";

        /// <summary>
        /// Compares base characters (for example, "a" &lt; "b") without considering accents, case, or tone marks.
        /// </summary>
        [EvalAtCompile]
        public const string Primary = "primary";

        /// <summary>
        /// Accents in the characters are considered secondary differences (for example, "as" &lt; "às" &lt; "at").
        /// Other differences between letters can also be considered secondary differences, depending on the language. A secondary difference is ignored when there is a primary difference anywhere in the strings.
        /// </summary>
        [EvalAtCompile]
        public const string Secondary = "secondary";

        /// <summary>
        /// Upper and lower case differences in characters are distinguished at the tertiary level (for example, "ao" &lt; "Ao" &lt; "aò"). In addition, a variant of a letter differs from the base form on the tertiary level (such as "A" and "?").
        /// A tertiary difference is ignored when there is a primary or secondary difference anywhere in the strings.
        /// </summary>
        [EvalAtCompile]
        public const string Tertiary = "tertiary";
    }

    [NonScript]
    public abstract class Tokenize
    {
        public static implicit operator Tokenize(string val)
        {
            return null;
        }

        /// <summary>
        /// Does not tokenize.
        /// </summary>
        [EvalAtCompile]
        public const string None = "none";

        /// <summary>
        /// Use the default for the locale (which may strip stop-words).
        /// Stop-words are common words that are stripped for purposes of indexing, i.e., "the", "a", "an", "is", etc.
        /// </summary>
        [EvalAtCompile]
        public const string Default = "default";

        /// <summary>
        /// Tokenizes all words.
        /// </summary>
        [EvalAtCompile]
        public const string All = "all";
    }

    public class IndexPropClause
    {        
        /// <summary>
        /// Name of property being indexed.
        /// </summary>
        public string Name;

        /// <summary>
        /// Indicates the string comparison routine used to order the index.
        /// </summary>
        public Collate Collate;

        /// <summary>
        /// Default value to set for this property at insertion time, if not present.
        /// </summary>
        public object Default;

        /// <summary>
        /// Indicates if words in strings should be broken up, i.e., should "Hello World" become "Hello" and "World" for purposes of indexing.
        /// </summary>
        public Tokenize Tokenize;

        /// <summary>
        /// "single" or "multi". Single property or multiple properties.
        /// </summary>
        //TODO:smaple conflict with comment:public string Type;
    }
}
